package com.cykj.eurekaclient.controller;

import com.alibaba.fastjson.JSONObject;
import com.cykj.eurekaclient.bean.*;

import com.cykj.eurekaclient.service.AdminService;
import com.cykj.eurekaclient.utils.JsonXMLUtils;
import com.cykj.eurekaclient.utils.sms.SMSTool;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
public class HelloController {

    @Autowired
    private AdminService adminService;

    @RequestMapping("/getUser")
    public BackUser getUser(@RequestBody BackUser user) {
        System.out.println("111");
        return user;
    }

    @RequestMapping(value = "/adminLogin")
    public String Login(@RequestBody BackUser user) {
        System.out.println("登录" + user.getAccount());
        BackUser user1 = adminService.Login(user);
        System.out.println(user1.getAccount());
        if (user1 != null) {
            System.out.println("123131231231");
            return "登录成功";
        }
        System.out.println("2222222222");
        return "账号密码不正确";
    }

    @RequestMapping("backUserGetCode")
    public String backUserGetCode(@RequestBody Map<String,String> data){
        System.out.println(data.get("telephoneNumber"));
        /* 第一步：随机产生4位验证码 */
        Random random = new Random();
        String code = "";
        while (code.length() < 4){
            code += random.nextInt(9)+"";
        }
        // 产生的4位随机验证码
        System.out.println(code);

        // 第二步，设置发送的短信内容
        String content = "【传一智慧公交】尊敬的用户，您的验证码为"+code+"，请于2分钟内正确输入。如非本人操作，请忽略此信息，请勿泄露给他人。";

        String success = SMSTool.sendVerificationCode(content,data.get("telephoneNumber"));
        if (success.equals("0")){
            return "200";
        }else {
            return "-200";
        }
    }

    @RequestMapping("getUserList")
    @ResponseBody
    public Map<String,Object> getUserList(@RequestBody PageConfig pageConfig){
        Map<String,Object> map = new HashMap<>();
        map.put("pageConfig",pageConfig);
        System.out.println(pageConfig.getSize());
        System.out.println(pageConfig.getPage());
        map.put("count",adminService.selectCount());
        map.put("userList",adminService.find(new RowBounds((pageConfig.getPage()-1)*pageConfig.getSize(),pageConfig.getSize())));
        return map;
    }

    //模糊查询
    @RequestMapping("selAllData")// findSite
    public Map<String,Object> findSite1(@RequestBody Map<String,Object> map) throws Exception {

        PageConfig pageConfig = null;
        BackUser backUser = null;
        if (map.get("pageConfig")!=null){
            pageConfig = JsonXMLUtils.map2obj((Map<String, Object>)map.get("pageConfig"),PageConfig.class);
        }
        if (map.get("backUser")!=null){
            backUser = JsonXMLUtils.map2obj((Map<String, Object>) map.get("backUser"),BackUser.class);
        }
        System.out.println("查询数据");
        if (pageConfig!=null && backUser != null){
            System.out.println(backUser.getName()+" "+pageConfig.getPage());
            Map<String,Object> nameMap = new HashMap<>();
            String name = "%" + backUser.getName() + "%";
            nameMap.put("pageConfig",pageConfig);
            nameMap.put("count",adminService.siteCount(name));
            nameMap.put("siteName",adminService.findSite1(new RowBounds((pageConfig.getPage() -1) * pageConfig.getSize(),pageConfig.getSize()),name));
            return nameMap;
        }else {
            return null;
        }

    }
    @RequestMapping("deleteRow1")
    public boolean deleteRow1(@RequestBody BackUser backUser){
        System.out.println("删除行");
        int id = (int) backUser.getId();
        System.out.println("删除id为："+id);
        return adminService.deleteRow1(id);
    }

    //修改
    @RequestMapping("updateRow1")
    public boolean updateRow1(@RequestBody BackUser backUser){
        System.out.println("修改状态密码");
        System.out.println(backUser.getId());
        System.out.println(backUser.getAccountState());
        BackUser sta = new BackUser();
        sta.setAccountState(backUser.getAccountState());
        sta.setId(backUser.getId());;
        sta.setPassword(backUser.getPassword());
        boolean b = adminService.updateRow1(String.valueOf(backUser.getAccountState()), backUser.getId(),backUser.getPassword());
        if (b) {
            return true;
        }else {
            return false;
        }
    }
    //----------------  添加---------------
    @RequestMapping("getTest1")
    public boolean getTest1(@RequestBody BackUser backUser) {
        System.out.println("进来了");
        System.out.println(backUser.getName());
        System.out.println(backUser.getAccount());
        System.out.println(backUser.getPassword());
        boolean b = adminService.insertSite1(backUser);
        if (b) {
            return true;
        }else {
            return false;
        }
    }

    @RequestMapping("getFUserList")
    @ResponseBody
    public Map<String,Object> getFUserList(@RequestBody PageConfig pageConfig){
        Map<String,Object> map = new HashMap<>();
        map.put("pageConfig",pageConfig);
        System.out.println(pageConfig.getSize());
        System.out.println(pageConfig.getPage());
        map.put("count",adminService.FselUserAll());
        map.put("fuserList",adminService.Ffind(new RowBounds((pageConfig.getPage()-1)*pageConfig.getSize(),pageConfig.getSize())));
        return map;
    }
    @RequestMapping("FdeleteRow")
    public boolean FdeleteRow(@RequestBody FrontUser frontUser){
        System.out.println("删除行");
        int id = (int) frontUser.getId();
        System.out.println("删除id为："+id);
        return adminService.FdeleteRow(id);
    }
    //----------------  添加---------------
    @RequestMapping("getFTest")
    public boolean getFTest(@RequestBody FrontUser frontUser) {
        System.out.println("进来了");
        System.out.println(frontUser.getName());
        System.out.println(frontUser.getAccount());
        System.out.println(frontUser.getPassword());
        boolean b = adminService.FinsertSite(frontUser);
        if (b) {
            return true;
        }else {
            return false;
        }
    }
    //模糊查询
    @RequestMapping("FselAllData")// findSite
    public Map<String,Object> FfindSite(@RequestBody Map<String,Object> map) throws Exception {

        PageConfig pageConfig = null;
        FrontUser frontUser = null;
        if (map.get("pageConfig")!=null){
            pageConfig = JsonXMLUtils.map2obj((Map<String, Object>)map.get("pageConfig"),PageConfig.class);
        }
        if (map.get("frontUser")!=null){
            frontUser = JsonXMLUtils.map2obj((Map<String, Object>) map.get("frontUser"),FrontUser.class);
        }
        System.out.println("查询数据");
        if (pageConfig!=null && frontUser != null){
            System.out.println(frontUser.getName()+" "+pageConfig.getPage());
            Map<String,Object> nameMap = new HashMap<>();
            String name = "%" + frontUser.getName() + "%";
            nameMap.put("pageConfig",pageConfig);
            nameMap.put("count",adminService.FsiteCount(name));
            nameMap.put("siteName",adminService.FfindSite(new RowBounds((pageConfig.getPage() -1) * pageConfig.getSize(),pageConfig.getSize()),name));
            return nameMap;
        }else {
            return null;
        }

    }
    //修改
    @RequestMapping("FupdateRow")
    public boolean FupdateRow(@RequestBody FrontUser frontUser){
        System.out.println("修改状态密码");
        System.out.println(frontUser.getId());
        System.out.println(frontUser.getAccountState());
        FrontUser sta = new FrontUser();
        sta.setAccountState(frontUser.getAccountState());
        sta.setId(frontUser.getId());;
        sta.setPassword(frontUser.getPassword());
        boolean b = adminService.FupdateRow(String.valueOf(frontUser.getAccountState()), frontUser.getId(),frontUser.getPassword());
        if (b) {
            return true;
        }else {
            return false;
        }
    }

    @RequestMapping("getPUserList")
    @ResponseBody
    public Map<String,Object> getPUserList(@RequestBody PageConfig pageConfig){
        Map<String,Object> map = new HashMap<>();
        map.put("pageConfig",pageConfig);
        System.out.println(pageConfig.getSize());
        System.out.println(pageConfig.getPage());
        map.put("count",adminService.PselUserAll());
        map.put("puserList",adminService.Pfind(new RowBounds((pageConfig.getPage()-1)*pageConfig.getSize(),pageConfig.getSize())));
        return map;
    }
    @RequestMapping("PdeleteRow")
    public boolean PdeleteRow(@RequestBody Parameter parameter){
        System.out.println("删除行");
        int id = (int) parameter.getId();
        System.out.println("删除id为："+id);
        return adminService.PdeleteRow(id);
    }
    //模糊查询
    @RequestMapping("PselAllData")// findSite
    public Map<String,Object> PfindSite(@RequestBody Map<String,Object> map) throws Exception {

        PageConfig pageConfig = null;
        Parameter parameter = null;
        if (map.get("pageConfig")!=null){
            pageConfig = JsonXMLUtils.map2obj((Map<String, Object>)map.get("pageConfig"),PageConfig.class);
        }
        if (map.get("parameter")!=null){
            parameter = JsonXMLUtils.map2obj((Map<String, Object>) map.get("parameter"),Parameter.class);
        }
        System.out.println("查询数据");
        if (pageConfig!=null && parameter != null){
            System.out.println(parameter.getName()+" "+pageConfig.getPage());
            Map<String,Object> nameMap = new HashMap<>();
            String name = "%" + parameter.getName() + "%";
            nameMap.put("pageConfig",pageConfig);
            nameMap.put("count",adminService.PsiteCount(name));
            nameMap.put("siteName",adminService.PfindSite(new RowBounds((pageConfig.getPage() -1) * pageConfig.getSize(),pageConfig.getSize()),name));
            return nameMap;
        }else {
            return null;
        }

    }
    @RequestMapping("getPTest")
    public boolean gePTest(@RequestBody Parameter parameter) {
        System.out.println("进来了");
        System.out.println(parameter.getName());
        System.out.println(parameter.getType());
        System.out.println(parameter.getParentId());
        boolean b = adminService.PinsertSite(parameter);
        if (b) {
            return true;
        }else {
            return false;
        }
    }
    //修改
    @RequestMapping("PupdateRow")
    public boolean PupdateRow(@RequestBody Parameter parameter){
        System.out.println("修改状态密码");
        System.out.println(parameter.getId());
        System.out.println(parameter.getName());
        System.out.println(parameter.getType());
        System.out.println(parameter.getParentId());
        Parameter sta = new Parameter();
        sta.setId(parameter.getId());
        sta.setName(parameter.getName());;
        sta.setType(parameter.getType());
        sta.setParentId(parameter.getParentId());
        boolean b = adminService.PupdateRow(parameter.getName(), parameter.getParentId(),parameter.getType(), parameter.getId());
        if (b) {
            return true;
        }else {
            return false;
        }
    }

    @RequestMapping("getqxgx")
    @ResponseBody
    public List<MenuInfo> getqxgx(@RequestBody MenuInfo menuInfo){
      List <MenuInfo> list =  adminService.qxgl();
      return list;
    }
    @RequestMapping("xlfind")
    public Map<String, Object> xlfind() {
        System.out.println("进来了");
        Map<String, Object> map = new HashMap<>();
        map.put("name",adminService.xlfind());
        return map;
    }
//奕豪
//----------------  标记站点，配置信息---------------  奕豪
@RequestMapping("getTest")
public String getTest(@RequestBody StationInfo stationInfo) {
    System.out.println("进来了");
    System.out.println(stationInfo.getName());
    System.out.println("经度" + stationInfo.getLongitude());
    System.out.println("纬度" + stationInfo.getLatitude());
    System.out.println("城市" + stationInfo.getCityStr());
    System.out.println("区/县" + stationInfo.getDistrict());
    List<StationInfo> findsite = adminService.findSiteNameInfo(stationInfo.getName());
    List<CityInfo> cityExist = adminService.selCityExist(stationInfo.getCityStr(),stationInfo.getDistrict());
    //判断：如果站点名称不存在 且 满足地点城市区域存在
    if (findsite.size()==0 && cityExist.size()!=0){
        if (stationInfo.getName()!=null){
            StationInfo sta = new StationInfo();
            sta.setName(stationInfo.getName());
            sta.setLongitude(stationInfo.getLongitude());
            sta.setLatitude(stationInfo.getLatitude());
            adminService.insertSite(sta,stationInfo.getDistrict());
            //全部条件均满足
            return "1";
        }else {
            //输入框内容为空回调
            return "3";
        }
    }else {
        return "2";
    }
}

    //---------------- 站点配置查询 ---------------  奕豪
    @RequestMapping("getSite")
    public Map<String,Object> getSite(@RequestBody Map<String,Object> map) throws Exception {
        System.out.println("站点配置查询");
        PageConfig pageConfig = null;
        StationInfo stationInfo = null;
        if (map.get("pageConfig")!=null){
            pageConfig = JsonXMLUtils.map2obj((Map<String, Object>)map.get("pageConfig"),PageConfig.class);
        }
        if (map.get("stationInfo")!=null){
            stationInfo = JsonXMLUtils.map2obj((Map<String, Object>) map.get("stationInfo"),StationInfo.class);
            System.out.println(stationInfo.getName() + ":**********");
        }
        Map<String,Object> site = new HashMap<>();
        String name = "%" + stationInfo.getName() + "%";
        site.put("pageConfig",pageConfig);
        site.put("count",adminService.siteCount(name));
        site.put("siteConfig",adminService.findSiteInfo(new RowBounds((pageConfig.getPage() -1) * pageConfig.getSize(),pageConfig.getSize()),name));
        return site;
    }

    //---------------- 站点配置删除数据 ---------------  奕豪
    @RequestMapping("deleteRow")
    public boolean deleteRow(@RequestBody StationInfo stationInfo){
        System.out.println("删除行");
        int id = (int) stationInfo.getId();
        System.out.println("--站点配置--删除id为："+id);
        return adminService.deleteRow(id);
    }

    //---------------- 站点配置编辑数据 ---------------  奕豪
    @RequestMapping("updateRow")
    public boolean updateRow(@RequestBody StationInfo stationInfo){
        System.out.println("编辑数据");
        System.out.println(stationInfo.getId());
        System.out.println(stationInfo.getName());
        System.out.println(stationInfo.getLongitude());
        System.out.println(stationInfo.getLatitude());
        System.out.println(stationInfo.getCityId());
        StationInfo sta = new StationInfo();
        sta.setName(stationInfo.getName());
        sta.setLongitude(stationInfo.getLongitude());
        sta.setLatitude(stationInfo.getLatitude());
        sta.setCityId(stationInfo.getCityId());
        boolean b = adminService.updateRow(sta, stationInfo.getId());
        if (b) {
            return true;
        }else {
            return false;
        }
    }

    //---------------- 线路配置查询数据 ---------------  奕豪
    @RequestMapping("getLine")
    public Map<String,Object> getLineInfo(@RequestBody Map<String,Object> map) throws Exception {
        System.out.println("线路配置查询");
        PageConfig pageConfig = null;
        RouteInfo routeInfo = null;
        if (map.get("pageConfig")!=null){
            pageConfig = JsonXMLUtils.map2obj((Map<String, Object>)map.get("pageConfig"),PageConfig.class);
        }
        if (map.get("routeInfo")!=null){
            routeInfo = JsonXMLUtils.map2obj((Map<String, Object>) map.get("routeInfo"),RouteInfo.class);
        }
        System.out.println(routeInfo.getRouteName());
        Map<String,Object> line = new HashMap<>();
        String name = "%" + routeInfo.getRouteName() + "%";
        line.put("pageConfig",pageConfig);
        line.put("count",adminService.routeCount(name));
        line.put("lineConfig",adminService.getLineInfo(new RowBounds((pageConfig.getPage() -1) * pageConfig.getSize(),pageConfig.getSize()),name));
        return line;
    }

    //---------------- 线路配置删除数据 ---------------  奕豪
    @RequestMapping("deleteRouteRow")
    public boolean deleteRouteRow(@RequestBody RouteInfo routeInfo){
        System.out.println("线路配置删除行");
        int id = (int) routeInfo.getId();
        System.out.println("--线路配置--删除id为："+id);
        return adminService.deleteRouteRow(id);
    }

    //---------------- 线路配置编辑数据 ---------------  奕豪
    @RequestMapping("updateRouteRow")
    public boolean updateRouteRow(@RequestBody RouteInfo routeInfo){
        System.out.println("线路配置--编辑数据");
        System.out.println(routeInfo.getId());
        System.out.println(routeInfo.getRouteName());
        System.out.println(routeInfo.getPrice());
        System.out.println(routeInfo.getRouteTime());
        System.out.println(routeInfo.getDriverPrice());
        System.out.println(routeInfo.getIntervalTime());
        RouteInfo route = new RouteInfo();
        route.setRouteName(routeInfo.getRouteName());
        route.setPrice(routeInfo.getPrice());
        route.setRouteTime(routeInfo.getRouteTime());
        route.setDriverPrice(routeInfo.getDriverPrice());
        route.setIntervalTime(routeInfo.getIntervalTime());
        boolean b = adminService.updateRouteRow(route, routeInfo.getId());
        if (b) {
            return true;
        }else {
            return false;
        }
    }

    //----------------  添加线路--配置信息---------------  奕豪
    @RequestMapping("insertRoute")
    public String insertRoute(@RequestBody RouteInfo routeInfo) {
        System.out.println("正在添加数据");
        System.out.println(routeInfo.getRouteName());
        System.out.println(routeInfo.getPrice());
        System.out.println(routeInfo.getRouteTime());
        System.out.println(routeInfo.getDriverPrice());
        System.out.println(routeInfo.getIntervalTime());
        List<RouteInfo> findRou = adminService.findRouteName(routeInfo.getRouteName());
        if (findRou.size()==0&&routeInfo.getRouteName()!=null&&routeInfo.getPrice()!=null
                &&routeInfo.getRouteTime()!=null&&routeInfo.getDriverPrice()!=null&&routeInfo.getIntervalTime()!=null){
            RouteInfo rou = new RouteInfo();
            rou.setRouteName(routeInfo.getRouteName());
            rou.setPrice(routeInfo.getPrice());
            rou.setRouteTime(routeInfo.getRouteTime());
            rou.setDriverPrice(routeInfo.getDriverPrice());
            rou.setIntervalTime(routeInfo.getIntervalTime());
            adminService.insertRoute(rou);
            return "1";
        }else {
            return "2";
        }
    }

    //---------------- 地图上显示所有站点 ---------------  奕豪
    @RequestMapping("positionAllSite")
    public List<StationInfo> positionAllSite(){
        System.out.println("地图上显示所有站点");
        return adminService.findLng();
    }

    //---------------- 班车班次时刻表配置查询 ---------------  奕豪
    @RequestMapping("getBusTime")
    public Map<String,Object> getBusTime(@RequestBody Map<String,Object> map) throws Exception {
        System.out.println("班车班次时刻表配置查询");
        PageConfig pageConfig = null;
        RouteTimeNode routeTimeNode = null;
        if (map.get("pageConfig")!=null){
            pageConfig = JsonXMLUtils.map2obj((Map<String, Object>)map.get("pageConfig"),PageConfig.class);
        }
        if (map.get("routeTimeNode")!=null){
            routeTimeNode = JsonXMLUtils.map2obj((Map<String, Object>) map.get("routeTimeNode"),RouteTimeNode.class);
        }
        System.out.println(routeTimeNode.getRouteStr()+"///////////");
        String name = "%" + routeTimeNode.getRouteStr() + "%";
        Map<String,Object> timeNode = new HashMap<>();
        timeNode.put("pageConfig",pageConfig);
        timeNode.put("count",adminService.selectBusTimeCount(name));
        timeNode.put("timeNode",adminService.getBusTime(new RowBounds((pageConfig.getPage() -1) * pageConfig.getSize(),pageConfig.getSize()),name));
        return timeNode;
    }

    //---------------- 班车班次时刻表配置删除数据 ---------------  奕豪
    @RequestMapping("deleteBusTimeRow")
    public boolean deleteBusTimeRow(@RequestBody RouteTimeNode routeTimeNode){
        System.out.println("班车班次时刻表配置删除行");
        int id = (int) routeTimeNode.getId();
        System.out.println("--班车班次时刻表--删除id为："+id);
        return adminService.deleteBusTimeRow(id);
    }

    //---------------- 班车班次时刻表配置 ** 下拉框取值 ---------------  奕豪
    @RequestMapping("routeIdOptions")
    public Map<String,Object> routeIdOptions(){
        System.out.println("routeIdOptions下拉框选项");
        Map<String,Object> routeIdMap = new HashMap<>();
        routeIdMap.put("routeIdOptions",adminService.routeIdOptions());
        return routeIdMap;
    }
    //---------------- 班车班次时刻表配置 ** 下拉框取值 ---------------  奕豪
    @RequestMapping("timePOptions")
    public Map<String,Object> timePOptions(){
        System.out.println("timePOptions下拉框选项");
        Map<String,Object> timePOptionsMap = new HashMap<>();
        timePOptionsMap.put("timePOptions",adminService.timePOptions());
        return timePOptionsMap;
    }

    //---------------- 班车班次时刻表配置 ** 下拉框取值 ---------------  奕豪
    @RequestMapping("stateOptions")
    public Map<String,Object> stateOptions(){
        System.out.println("stateOptions下拉框选项");
        Map<String,Object> stateOptionsMap = new HashMap<>();
        stateOptionsMap.put("stateOptions",adminService.stateOptions());
        return stateOptionsMap;
    }

    //----------------  添加时刻表--配置信息---------------  奕豪
    @RequestMapping("insertBusTime")
    public boolean insertBusTime(@RequestBody RouteTimeNode routeTimeNode) {
        System.out.println("时刻表正在添加数据");
        System.out.println(routeTimeNode.getRouteStr());
        System.out.println(routeTimeNode.getTimeParagraphStr());
        System.out.println(routeTimeNode.getTimeNode());
        System.out.println(routeTimeNode.getState());
        RouteTimeNode rou = new RouteTimeNode();
        rou.setRouteStr(routeTimeNode.getRouteStr());
        rou.setTimeParagraphStr(routeTimeNode.getTimeParagraphStr());
        rou.setTimeNode(routeTimeNode.getTimeNode());
        rou.setState(routeTimeNode.getState());
        boolean b = adminService.insertBusTime(rou);
        if (b) {
            return true;
        }else {
            return false;
        }
    }

    //---------------- 时刻表配置编辑数据 ---------------  奕豪
    @RequestMapping("updateBusTimeRow")
    public boolean updateBusTimeRow(@RequestBody RouteTimeNode routeTimeNode){
        System.out.println("时刻表配置--编辑数据");
        System.out.println(routeTimeNode.getId());
        System.out.println(routeTimeNode.getRouteStr());
        System.out.println(routeTimeNode.getTimeParagraphStr());
        System.out.println(routeTimeNode.getTimeNode());
        System.out.println(routeTimeNode.getState());
        boolean b = adminService.updateBusTimeRow(routeTimeNode.getRouteStr(),routeTimeNode.getTimeParagraphStr(),
                routeTimeNode.getTimeNode(),routeTimeNode.getState(),routeTimeNode.getId());
        if (b) {
            return true;
        }else {
            return false;
        }
    }

    //---------------- 城市信息配置查询 ---------------  奕豪
    @RequestMapping("getCityInfo")
    public Map<String,Object> getCityInfo(@RequestBody Map<String,Object> map) throws Exception {
        System.out.println("城市信息配置查询");
        PageConfig pageConfig = null;
        CityInfo cityInfo = null;
        if (map.get("pageConfig")!=null){
            pageConfig = JsonXMLUtils.map2obj((Map<String, Object>)map.get("pageConfig"),PageConfig.class);
        }
        if (map.get("cityInfo")!=null){
            cityInfo = JsonXMLUtils.map2obj((Map<String, Object>) map.get("cityInfo"),CityInfo.class);
        }
        System.out.println(cityInfo.getName());
        Map<String,Object> city = new HashMap<>();
        String name = "%" + cityInfo.getName() + "%";
        city.put("pageConfig",pageConfig);
        city.put("count",adminService.cityCount(name));
        city.put("cityConfig",adminService.getCityInfo(new RowBounds((pageConfig.getPage() -1) * pageConfig.getSize(),pageConfig.getSize()),name));
        return city;
    }

    //---------------- 城市信息配置--添加数据 ---------------  奕豪
    @RequestMapping("insertCity")
    public String insertCity(@RequestBody CityInfo cityInfo){
        System.out.println("城市信息配置--增加");
        System.out.println(cityInfo.getName() + "," + cityInfo.getParentName() + "," + cityInfo.getDistrict());
        List<CityInfo> findCityName = adminService.selCityExist(cityInfo.getName(),cityInfo.getDistrict());
        //判断城市名是否存在
        if (findCityName.size()==0){
            if (cityInfo.getName()!=null && cityInfo.getParentName()!=null && cityInfo.getDistrict()!=null ){
                // 条件全满足的情况下
                adminService.insertCity(cityInfo.getName(), cityInfo.getParentName(),cityInfo.getDistrict());
                return "1";
            }else {
                //缺斤少两的情况
                return "3";
            }
        }else {
            //要添加的城市地区已添加过，不能重复添加
            return "2";
        }
    }

    //---------------- 城市信息配置--修改数据 ---------------  奕豪
    @RequestMapping("updateCityRow")
    public String updateCityRow(@RequestBody CityInfo cityInfo){
        System.out.println("城市信息配置--编辑");
        System.out.println(cityInfo.getName() + "," + cityInfo.getParentName() + "," + cityInfo.getId());
        List<CityInfo> findCityName = adminService.selCityExist(cityInfo.getName(),cityInfo.getDistrict());
        if (findCityName.size()==0) {
            adminService.updateCityRow(cityInfo.getName(),cityInfo.getParentName(),cityInfo.getDistrict(),cityInfo.getId());
            return "1";
        }else {
            return "2";
        }
    }

    //---------------- 城市信息配置删除数据 ---------------  奕豪
    @RequestMapping("deleteCityInfoRow")
    public boolean deleteCityInfoRow(@RequestBody CityInfo cityInfo){
        System.out.println("城市信息配置删除行");
        int id = (int) cityInfo.getId();
        System.out.println("--城市信息配置--删除id为："+id);
        return adminService.deleteCityInfoRow(id);
    }



    //---------------- 行经站点配置查询 ---------------  奕豪
    @RequestMapping("getTravelSite")
    public Map<String,Object> getTravelSite(@RequestBody Map<String,Object> map) throws Exception {
        System.out.println("行经站点配置查询");
        PageConfig pageConfig = null;
        StationAssign stationAssign = null;
        if (map.get("pageConfig")!=null){
            pageConfig = JsonXMLUtils.map2obj((Map<String, Object>)map.get("pageConfig"),PageConfig.class);
        }
        if (map.get("stationAssign")!=null){
            stationAssign = JsonXMLUtils.map2obj((Map<String, Object>) map.get("stationAssign"),StationAssign.class);
        }
        System.out.println(stationAssign.getRouteStr());
        Map<String,Object> travelSite = new HashMap<>();
        String name = "%" + stationAssign.getRouteStr() + "%";
        travelSite.put("pageConfig",pageConfig);
        travelSite.put("count",adminService.selectTravelSiteCount(name));
        travelSite.put("travelSiteConfig",adminService.getTravelSite(new RowBounds((pageConfig.getPage() -1) * pageConfig.getSize(),pageConfig.getSize()),name));
        return travelSite;
    }

    //---------------- 行经站点配置 ** 下拉框取值 ---------------  奕豪
    @RequestMapping("routeNameOptions")
    public Map<String,Object> routeNameOptions(){
        System.out.println("routeNameOptions下拉框选项");
        Map<String,Object> routeNameMap = new HashMap<>();
        routeNameMap.put("routeNameOptions",adminService.routeNameOptions());
        return routeNameMap;
    }
    //---------------- 行经站点配置 ** 下拉框取值 ---------------  奕豪
    @RequestMapping("stationOptions")
    public Map<String,Object> stationOptions(){
        System.out.println("stationOptions下拉框选项");
        Map<String,Object> stationMap = new HashMap<>();
        stationMap.put("stationOptions",adminService.stationOptions());
        return stationMap;
    }

    //---------------- 行经站点配置删除数据 ---------------  奕豪
    @RequestMapping("deleteTravelSiteRow")
    public boolean deleteTravelSiteRow(@RequestBody StationAssign stationAssign){
        System.out.println("行经站点配置删除行");
        int id = (int) stationAssign.getId();
        System.out.println("--行经站点--删除id为："+id);
        return adminService.deleteTravelSiteRow(id);
    }

    //----------------  添加行经站点--配置信息---------------  奕豪
    @RequestMapping("insertTravelSite")
    public String insertTravelSite(@RequestBody StationAssign stationAssign) {
        System.out.println("行经站点表正在添加数据");
        System.out.println(stationAssign.getRouteStr());
        System.out.println(stationAssign.getStationStr());
        System.out.println(stationAssign.getSequence());
        List<StationAssign> findTravelSiteName = adminService.findTravelSiteName(stationAssign.getStationStr(),stationAssign.getSequence());
        if (findTravelSiteName.size()==0){
            if (stationAssign.getRouteStr()!=null&&stationAssign.getStationStr()!=null){
                adminService.insertTravelSite(stationAssign.getRouteStr(),stationAssign.getStationStr(),stationAssign.getSequence());
                return "1";
            }else {
                return "3";
            }
        }else {
            return "2";
        }
    }

    //---------------- 行经站点配置编辑数据 ---------------  奕豪
    @RequestMapping("updateTravelSiteRow")
    public boolean updateTravelSiteRow(@RequestBody StationAssign stationAssign){
        System.out.println("行经站点表配置--编辑数据");
        System.out.println(stationAssign.getId());
        System.out.println(stationAssign.getRouteStr());
        System.out.println(stationAssign.getStationStr());
        System.out.println(stationAssign.getSequence());
        boolean b = adminService.updateTravelSiteRow(stationAssign.getRouteStr(),stationAssign.getStationStr(),
                stationAssign.getSequence(),stationAssign.getId());
        if (b) {
            return true;
        }else {
            return false;
        }
    }

    //---------------- 收银统计 ---------------  奕豪
    @RequestMapping("findCollectMoney")
    public FrontUserFlowRecord findAllAgeP() {
        //new一个结果集
        FrontUserFlowRecord frontUserFlowRecord = new FrontUserFlowRecord();
        //调用查询方法
        List<FrontUserFlowRecord> list = adminService.findCollectMoney();
        //定义List集合转化为纯数组
        List<Object> ints = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            //获取
            ints.add(list.get(i).getTradeMoney());
        }
        List<Object> intStr = new ArrayList<>();
        List<FrontUserFlowRecord> listStr = adminService.collectMoneyRoute();
        for (int i = 0; i < listStr.size(); i++) {
            //获取
            intStr.add(listStr.get(i).getRouteStr());
        }
        frontUserFlowRecord.setAllTakeIn(adminService.allTakeIn());
        frontUserFlowRecord.setData(ints);
        frontUserFlowRecord.setRouteData(intStr);
        return frontUserFlowRecord;
    }
}
